package com.wn.equipment.service.imp;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.EquipmentManagement;
import com.wn.entity.Feedback;
import com.wn.equipment.mapper.FeedBackMapper;
import com.wn.equipment.service.FeedBackService;
import com.wn.equipment.vo.FeedbackVo;
import com.wn.utils.PageBeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhairenhao
 * @date 2022/10/21 15:16
 */
@Service
@Slf4j
public class FeedBackServiceImp implements FeedBackService {
    @Autowired
    FeedBackMapper feedBackMapper;

    @Override
    public void insert(Feedback feedback) {
        feedBackMapper.insert(feedback);
    }

    @Override
    public void update(Feedback feedback) {
        feedBackMapper.update(feedback);
    }

    @Override
    public Feedback getById(int id) {
        return feedBackMapper.getById(id);
    }

    @Override
    public List<Feedback> getByCondition(Feedback feedback) {
        return feedBackMapper.getByCondition(feedback);
    }

    @Override
    public PageBean<Feedback> getEquipmentByPages(FeedbackVo feedbackVo) {
        Page<Feedback> page = PageHelper.startPage(feedbackVo.getCurrPage(), feedbackVo.getPageSize());
        List<Feedback> list = feedBackMapper.getByCondition(feedbackVo.getFeedback());
        PageBean<Feedback> pageBean = PageBeanUtil.getPageBean(list, page, feedbackVo.getCurrPage(), feedbackVo.getPageSize());
        return pageBean;
    }
}
